package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.entity.Tailor;
import ysc.cqnu.operdb.mapper.CaiJianMapper;
import ysc.cqnu.operdb.service.CheckCaiJianInfoService;

@Service
public class CheckCaiJIanInfoServiceImpl implements CheckCaiJianInfoService {
    @Autowired
    private Tailor tailor;
    @Autowired
    private ResultData resultData;
    @Autowired
    private CaiJianMapper caiJianMapper;
    @Override
    public ResultData checkCaiJianInfoService(String caijianname, String renwu, String yongtu, String juti, String uploader, String uploadDate) {
        try {
            tailor = caiJianMapper.chazhaoCaijianInfo(caijianname,renwu,yongtu,juti,uploader,uploadDate);

            if(tailor!=null){
                int count = caiJianMapper.count();
                int site = caiJianMapper.caijianInfoSite(String.valueOf(tailor.getId()));
                tailor.Count=String.valueOf(count);
                tailor.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=tailor;
                return resultData;
            }
            else {
                resultData.flag="CaijianInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
